package net.lab1024.sa.admin.module.business.erp.controller;

import net.lab1024.sa.admin.module.business.erp.domain.form.add.TmsordAddForm;

import net.lab1024.sa.admin.module.business.erp.domain.form.query.TmsordQueryForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.update.TmsordUpdateForm;
import net.lab1024.sa.admin.module.business.erp.domain.vo.TmsordVO;
import net.lab1024.sa.admin.module.business.erp.service.TmsordService;
import net.lab1024.sa.admin.module.business.goods.domain.vo.GoodsExcelVO;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.common.util.SmartExcelUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

/**
 * BOM表 Controller
 *
 * @Author AKITA
 * @Date 2025-08-15 10:54:43
 * @Copyright AKITA
 */

@RestController
@Tag(name = "BOM表")
public class TmsordController {

    @Resource
    private TmsordService tmsordService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/tmsord/queryPage")
    public ResponseDTO<PageResult<TmsordVO>> queryPage(@RequestBody @Valid TmsordQueryForm queryForm) {
        return ResponseDTO.ok(tmsordService.queryPage(queryForm));
    }

    @Operation(summary = "导出 @author 卓大")
    @PostMapping("/tmsord/export")
    public void export(@RequestBody TmsordQueryForm queryForm,HttpServletResponse response) throws IOException {
        List<TmsordVO> list = tmsordService.getList(queryForm);
        SmartExcelUtil.exportExcel(response,"考勤列表.xlsx","考勤",TmsordVO.class, list);
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/tmsord/add")
    public ResponseDTO<String> add(@RequestBody @Valid TmsordAddForm addForm) {
        return tmsordService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/tmsord/update")
    public ResponseDTO<String> update(@RequestBody @Valid TmsordUpdateForm updateForm) {
        return tmsordService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/tmsord/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return tmsordService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/tmsord/delete/{id}")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return tmsordService.delete(id);
    }



}
